#include "BBDataManager.h"
#include "BBDataModel.h"



BBDataManager::BBDataManager( void )
{

}

BBDataManager::~BBDataManager( void )
{

}

BBDataModel* BBDataManager::createDataObject( const char* xmlPath )
{
	return NULL;
}

BBDataModel* BBDataManager::getDataObjByKey( char* key )
{
	if(key == NULL)
		return NULL;
	if(m_DataObjPool.find(key) != m_DataObjPool.end())
		return m_DataObjPool[key];
	return NULL;
}

void BBDataManager::addDataObj( char* key,BBDataModel* obj )
{
	if(key == NULL)
		return;
	m_DataObjPool[key] = obj;
}

bool BBDataManager::isHasDataObj( char* key )
{
	return (m_DataObjPool.find(key) != m_DataObjPool.end());
}

void BBDataManager::removeDataObjByKey( char* key )
{
	if(isHasDataObj(key))
	{
		m_DataObjPool.erase(m_DataObjPool.find(key));
	}
}

BBDataModelProxy* BBDataManager::getDataProxy( char* key )
{
	BBDataModel* obj = getDataObjByKey(key);
	if(obj == NULL)
		return NULL;
	return NULL;
}

void BBDataManager::Clear()
{
	std::map<char*,BBDataModel*>::iterator itor = m_DataObjPool.begin();
	for (;itor!=m_DataObjPool.end();itor++)
	{
		m_DataObjPool.erase(itor);
	}
	m_DataObjPool.clear();
}

void BBDataManager::purgeDataManager()
{
	BB_SAFE_DELETE(_mInstance);
}
